/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

/**
 *
 * @FernandoOliveira Java
 */

/*
 * Classe de Conexao Banco Oracle
 */
public class BancoDao {
   public Connection Oracle(){
       Connection conn = null;
       try {
           Class.forName("oracle.jdbc.driver.OracleDriver");
       } catch (Exception e) {
       }
       try {
           conn = DriverManager.getConnection("jdbc:oracle:thin:@10.0.0.111:1521:bdmoldenox","desenvolver","desenvolver");
           System.out.println("Conexao realizada com sucesso");
       } catch (Exception e) {
           System.out.println("Não foi possivel conectar");
       }
       return conn;
   } 
    
   
   public Connection MySql(){
		Connection conn = null;
		try {
			Class.forName("com.mysql.jdbc.Driver");
		} catch (Exception e) {
			// TODO: handle exception
		}try {
			conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/Desenvolver","root","desenvolver");
			System.out.println("Conectado com sucesso !");
		} catch (Exception e) {
                    System.out.println("Não conectado !");
			// TODO: handle exception
		}
		return conn;
	}
	
   public boolean result = false;
   public String valor = "";
   

   
   public boolean VerificarUsuario(String Username, String Pwd_net){
           
       String sql = "";
       Connection conn = MySql();
       sql = ("SELECT * from TB_Users WHERE USERNAME =? AND PWD_NET=?");
       try {
           PreparedStatement st = conn.prepareStatement(sql);
           st.setString(1, Username);
           st.setString(2, Pwd_net);
           ResultSet rs = st.executeQuery();
           if (rs.next()){
               result = true;
               valor = rs.getString("level");
           }
       } catch (Exception e) {
           System.out.println("erro");
       }
       return result;
   }
    
}
